/**
 * 大文件传输测试,给服务器上传一个大文件,服务器将文件保存下来，观察处理结果
 * 上次的文件和服务器保存的文件一致
 */

// 创建一个大文件
// dd if=/dev/zero of=./hello.txt bs=1G count=1

#include "../source/server.hpp"
#include "../source/http/http.hpp"

int main()
{
    // 创建客户端连接
    Socket clientsock;
    clientsock.CreateClient(8080, "127.0.0.1");
    std::string req = "PUT /1234.txt HTTP/1.1\r\nConnection: keep-alive\r\n";
    std::string body;
    Util::ReadFile("./hello.txt", &body);
    req += "Content-Length: " + std::to_string(body.size()) + "\r\n\r\n";

    assert(clientsock.Send(req.c_str(), req.size()) != -1);
    assert(clientsock.Send(body.c_str(), req.size()) != -1);
    char buffer[1024] = {0};
    assert(clientsock.Recv(buffer, 1023) != -1);
    LogMessage(DEBUG, "[%s]", buffer);
    sleep(15);

    clientsock.Close();
    return 0;
}
